<extend name="Public:base" />
<block name="title">添加病例</block>
<block name="content">
    <webuploadercss />
    <webuploaderjs />
    <form id="ajaxForm">
        <div class="page__bd">
            <div class="weui-panel__bd ">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label ">患者姓名</label></div>
                <div class="weui-cell__bd ">
                    <input type="text" name="name" id="name" class="input_border weui-input " />
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label ">疾病类型</label></div>
                <div class="weui-cell__bd sele_xial ">
                    <select class="weui-select input_border " name="cateid">
                        <option value="0">请选择疾病类型</option>
                        <foreach name="catelist" item="vo">
                            <option value="{$vo['id']}">{$vo['title']}</option>
                        </foreach>
                    </select>
                </div>
            </div>
            <!--<div class="weui-cell beizhu_kuang">
                <div class="weui-cell__hd"><label class="weui-label ">病例图片</label></div>
                <div class="weui-cell__bd ">
                    <a href="" class=" " >
                        +
                    </a>
                </div>
            </div>-->
            <div class="weui-cell weui-tag">
                <webuploader name="pic" url="{:U('Home/User/ajax_upload')}" word="或将照片拖到这里，单次最多可选300张" />
                <!--  自定义附加字段：<input type="text" name="extend" value="上传的文件描述"> -->
            </div>
            <div class="weui-cell beizhu_kuang">
                <div class="weui-cell__hd"><label class="weui-label ">备注信息</label></div>
                <div class="weui-cell__bd ">
                    <textarea class="weui-textarea" placeholder="请输入文本" rows="3" name="remarks"></textarea>
                </div>
            </div>
            <div class="button-sp-area xinxi_but_area">
                <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default">返回</a>
                <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary" id="add">添加</a>
            </div>
        </div>
        </div>
    </form>
    <script type="text/javascript">
        $("#add").click(function(){
            var name    = $("#name").val();
            var cateid  = $("#cateid option:selected").val();
            if(name == ''){
                layer.msg('请填写患者名称！');
                return false;
            }
            if(cateid == ''){
                layer.msg('请选择疾病类型！');
                return false;
            }
            var formData = $('#ajaxForm').serialize();
            $.ajax({
                type:'post',
                url:'__MODULE__/User/patientadd',
                data:formData,
                cache:false,
                dataType:'json',
                success:function(res){
                    if(res.code == 0){
                        layer.msg(res.msg,function () {
                            window.location.href = res.url;
                        });
                        return false;
                    }else{
                        layer.msg(res.msg);
                        return false;
                    }
                }
            });
        });
    </script>
</block>